package ua.kpi.javaTraining;

import java.util.ArrayList;

/**
 * Class describing a group of students
 * 
 * @author Timur Suleimanov
 * @param groupName
 *            Stands for group name
 */
public class Group {
	private ArrayList<Student> students;
	private String groupName;

	public Group(String groupName) {
		this.groupName = groupName;
		students = new ArrayList<Student>();
	}

	public String getGroupName() {
		return groupName;
	}

	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}

	public Student getStudent(int index) {
		return students.get(index);
	}

	/**
	 * Adding new students to the group
	 * 
	 * @param newStudent
	 *            Student to add
	 */
	public void addStudent(Student newStudent) {
		students.add(newStudent);
	}

	/**
	 * Deleting student from a group
	 * 
	 * @param studentToDelete
	 *            Student to delete
	 */
	public void deleteStudent(Student studentToDelete) {
		int index = students.indexOf(studentToDelete);
		if (index >= 0) {
			students.remove(index);
		}
	}

	public String toString() {
		return "Group name = " + groupName + " Students:" + students.toString();
	}

}